package metrics_sql

const (
	MetricsList = `
from(bucket: "data")
  |> range(start: %v, stop: %v)
  |> filter(fn: (r) => r["_measurement"] == "prometheus_remote_write")
  |> filter(fn: (r) => r["_field"] == "metrics")
  |> filter(fn: (r) => r["organize"] == "gluenets")
  |> last()
  |> map(fn: (r) => ({_field:r._field,_value:r._value,_time:r._time,platform:r["platform"],object:r["object"],label:r["label"]}))
  |> group(columns: ["platform","label","object"])
  |> count()
`

	MachineKubernets = `
object = "%v"
platform = "%v"
metric = "%v"
guid = "%v"
child = /^(%v)$/

from(bucket: "data")
  |> range(start: %v, stop: %v)
  |> filter(fn: (r) => r["_measurement"] == "prometheus_remote_write")
  |> filter(fn: (r) => r["_field"] == "metrics")
  |> filter(fn: (r) => r["label"] == metric)
  |> filter(fn: (r) => r["platform"] == platform)
  |> filter(fn: (r) => r["object"] == object)
  |> filter(fn: (r) => r["agent_guid"] == guid)
  |> filter(fn: (r) => r["host_name"] =~ child)
`
	MachineGluenets = `
object = "%v"
platform = "%v"
metric = "%v"
guid = "%v"
child = /^(%v)$/

start = %v
end = %v


from(bucket: "data")
  |> range(start: start, stop: end)
  |> filter(fn: (r) => r["_measurement"] == "prometheus_remote_write")
  |> filter(fn: (r) => r["_field"] == "metrics")
  |> filter(fn: (r) => r["label"] == metric)
  |> filter(fn: (r) => r["platform"] == platform)
  |> filter(fn: (r) => r["object"] == object)
  |> filter(fn: (r) => r["agent_guid"] == guid)
  |> filter(fn: (r) => r["host_name"] =~ child)
`
	ApplicationKubernets = `
object = "%v"
platform = "%v"
metric = "%v"
guid = "%v"
child = /^(%v)$/

from(bucket: "data")
  |> range(start: %v, stop: %v)
  |> filter(fn: (r) => r["_measurement"] == "prometheus_remote_write")
  |> filter(fn: (r) => r["_field"] == "metrics")
  |> filter(fn: (r) => r["label"] == metric)
  |> filter(fn: (r) => r["platform"] == platform)
  |> filter(fn: (r) => r["object"] == object)
  |> filter(fn: (r) => r["application_guid"] == guid)
  |> filter(fn: (r) => r["container"] =~ child)
`
	ApplicationGluenets = `
object = "%v"
platform = "%v"
metric = "%v"

ct = /%v_(%v)+/

start = %v
end = %v



from(bucket: "data")
  |> range(start: start, stop: end)
  |> filter(fn: (r) => r["_measurement"] == "prometheus_remote_write")
  |> filter(fn: (r) => r["_field"] == "metrics")
  |> filter(fn: (r) => r["label"] == metric)
  |> filter(fn: (r) => r["platform"] == platform)
  |> filter(fn: (r) => r["object"] == object)
  |> filter(fn: (r) => r["container"] =~ ct)
  |> filter(fn: (r) => r["agent_guid"] != "")
`
)
